<?php
function smarty_block_permission($params, $content, &$smarty, $repeat) {
	if(!$repeat) {

		$permUser		= $params['permUser'];
		$permissions	= $permUser->getUserProfilePermission();
		$isFriend		= $params['isFriend'];
		$permCheck		= $params['permCheck'];
		$userLoggedIn	= $smarty->get_template_vars('_userLoggedIn');
		$user			= $smarty->get_template_vars('user');

		$permission = (int)$permissions->checkPermission($permCheck);
		$userPermission = 0;

		if($userLoggedIn && $user->getId() == $permUser->getId()) {
			$userPermission = 3;
		}elseif($isFriend){
			$userPermission = 2;
		}elseif($userLoggedIn){
			$userPermission = 1;
		}

		return  $userPermission>=$permission?$content:'';

		
	}
}